
/**
 * Created by Dalyn on 2017/3/16.
 * 产品-列表信息组件
 */

import React , {Component}from 'react';
import ReactKey from "../../util/ReactKey"

export default class Product_item extends React.Component{
     constructor(props){
         super(props);
         this.state={
             flag:false,
             hintTools:true,
             hintText:''
         };
         this.style={
             hint_tools_none:{
             display: 'none',
             backgroundColor: '#ffffff',
             position:'absolute',
             width: 'auto',
             top: '295px',
             left: '425px',
            },
             hint_tools_block:{
                 display: 'block',
                 backgroundColor: '#ffffff',
                 position:'absolute',
                 width: 'auto',
                 top: '295px',
                 left: '425px',
             }
         };
     }

    componentWillMount(){
        // this.partyBEnid = this.props.item.partyBEnid
     }
     onchose(){

     }
     unchose(){
         console.warn('hei')
         this.refs._radioBtn.checked = false
         // this.setState={
         //     flag:false
         // };
     }
    ontouch(){
         /*每条item都有一个自己的状态值*/
         // console.log(this.refs._radioBtn.checked)
        this.setState({
            flag:this.refs._radioBtn.checked
        },()=>{
            let isSelectAll = this.refs._radioBtn.checked;
            if(!isSelectAll){
                this.props._isallclick(isSelectAll)
            }
        })
    }
    /*产品对应字段*/
    goodsInfoList(){
        let goodsProperty = this.props.goodsProperty.split(",");
        // console.log(goodsProperty)
        return goodsProperty.map((item,index)=>{
            // console.log(item)
            // console.log(this.props.goodsItem[item])
            return (
                    <td
                          key={ReactKey.key} title={this.props.goodsItem[item]}>{this.props.goodsItem[item]}</td>

            )
        })
    }
    render(){
        return(
            <tr>
                <td>
                    <input className="product_set_cb" type="checkbox" ref={"_radioBtn"} onChange={this.ontouch.bind(this)}/>
                </td>
                <td>{parseInt(this.props.index+1)}</td>
                {
                    this.goodsInfoList()
                }
                <td style={this.state.hintTools ? this.style.hint_tools_none:this.style.hint_tools_block}>
                    {this.state.hintText}
                </td>
            </tr>
        );
    }
}